package com.tjec.project.projectWorkbench.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.projectWorkbench.domain.BmsAgencyNo;
import com.tjec.project.projectWorkbench.domain.BmsCostNo;
import com.tjec.project.projectWorkbench.domain.BmsReportNo;
import com.tjec.project.projectWorkbench.service.IBmsCostNoService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 造价报告号Controller
 * 
 * @author pangyongfeng
 * @date 2020-08-05
 */
@RestController
@RequestMapping("/projectWorkbench/bmsCostNo")
public class BmsCostNoController extends BaseController
{
    @Autowired
    private IBmsCostNoService bmsCostNoService;

    /**
     * 查询造价报告号列表
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:bmsCostNo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsCostNo bmsCostNo)
    {
        startPage();
        List<BmsCostNo> list = bmsCostNoService.selectBmsCostNoList(bmsCostNo);
        return getDataTable(list);
    }

    /**
     * 导出造价报告号列表
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:bmsCostNo:export')")
    @Log(title = "造价报告号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmsCostNo bmsCostNo)
    {
        List<BmsCostNo> list = bmsCostNoService.selectBmsCostNoList(bmsCostNo);
        ExcelUtil<BmsCostNo> util = new ExcelUtil<BmsCostNo>(BmsCostNo.class);
        return util.exportExcel(list, "造价报告号");
    }

    /**
     * 获取造价报告号详细信息
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:bmsCostNo:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(bmsCostNoService.selectBmsCostNoByGuid(guid));
    }

    /**
     * 新增造价报告号
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:bmsCostNo:add')")
    @Log(title = "造价报告号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsCostNo bmsCostNo)
    {
        return AjaxResult.success(bmsCostNoService.insertBmsCostNo(bmsCostNo));
    }

    /**
     * 修改造价报告号
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:bmsCostNo:edit')")
    @Log(title = "造价报告号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsCostNo bmsCostNo)
    {
        return toAjax(bmsCostNoService.updateBmsCostNo(bmsCostNo));
    }

    /**
     * 删除造价报告号
     */
    //@PreAuthorize("@ss.hasPermi('projectWorkbench:bmsCostNo:remove')")
    @Log(title = "造价报告号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(bmsCostNoService.deleteBmsCostNoByGuids(guids));
    }
    
    @GetMapping("/checkBmsCostNo")
    public AjaxResult checkBmsCostNo(BmsCostNo bmsCostNo)
    {
        return AjaxResult.success(bmsCostNoService.checkBmsCostNo(bmsCostNo));
    }
    
    /**
     * 成果校审获取报告类型和报告号
     */
    //@PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/getCostTypeList")
    public AjaxResult getCostTypeList(BmsCostNo bmsCostNo)
    {
        List<BmsCostNo> list = bmsCostNoService.selectCostTypeAndNoList(bmsCostNo);
        return AjaxResult.success(list);
    }

    /**
     * 更新造价报告号历史表状态为“已迁移”
     *
     * @param bmsCostNo
     * @return
     */
    @Log(title = "造价报告号历史数据迁移", businessType = BusinessType.UPDATE)
    @PutMapping("/updateBmsCostNoHistory")
    public AjaxResult updateBmsCostNoHistory(@RequestBody BmsCostNo bmsCostNo)
    {
        return AjaxResult.success(bmsCostNoService.updateBmsCostNoHistory(bmsCostNo));
    }
}
